package com.zhyt.intelligentpipeline.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhyt.intelligentpipeline.model.CorrosionDetection;
import com.zhyt.intelligentpipeline.model.TransferPressure;
import com.zhyt.intelligentpipeline.service.TransferPressureService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/transferPressure")
public class TransferPressureController {
    @Resource
    private TransferPressureService transferPressureService;
    @GetMapping
    public List<TransferPressure>getAll(){
        return transferPressureService.list();
    }

    //分页
    @GetMapping("page/{page}/num/{num}")
    public IPage<TransferPressure> getPage(@PathVariable Integer page, @PathVariable Integer num)
    {
        IPage<TransferPressure>pages=new Page<>(page,num);
        return transferPressureService.page(pages);
    }
    //修改
    @PutMapping
    public Boolean update(@RequestBody TransferPressure transferPressure)
    {
        return transferPressureService.updateById(transferPressure);
    }
    /**
     * 删除压力
     */
    @DeleteMapping("delete/{id}")//这里面的id是和形参中的id是相应的才能传过去
    public Boolean delete(@PathVariable String id)
    {
        return transferPressureService.removeById(id);
    }

}
